home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Magnum One
/
Magnum One (Mid-American Digital) (Disc Manufacturing).iso
/
d12
/
c_lib.arc
/
PCISRSTK.C
< prev
next >
Wrap
Text File
|
1990-08-09
|
2KB
|
67 lines
/**
*
* Name pcisrstk -- Create the Interrupt Service Routine stack
*
* Synopsis ercode = pcisrstk(stksize);
* int ercode Error return code
* int stksize Desired stack size
*
* Description Interrupt service routines require their own stack.
* This function must be called before any ISR is set up
* so that stack space can be allocated. The stksize,
* which must accommodate all ISRs, is allocated from
* the heap, and its segment and offset address are stored
* in the global variables, isrss and isrstk_base. These
* values are passed to the ISR setup function, PCSETISR,
* and the ISR function dispatcher, INVISR.
*
* Returns If the requested size is not available, 1 is returned
* as an error value; otherwise 0 is returned. The global
* variables isrss and isrstk_base are initialized.
*
* Version 1.1 (C)Copyright Blaise Computing Inc. 1983, 1984
*
**/
#include <compiler.h>
#if LDATA
#define NULL 0L
#else
#define NULL 0
#endif
unsigned isrss; /* ISR stack segment */
unsigned isrstk_base; /* Bottom of ISR stack */
int pcisrstk(stksize)
int stksize;
{
char *pstk,*calloc();
unsigned cs,ss,ds,es;
#if CI201A & LDATA
unsigned long ptrtoabs();
#endif
pstk = calloc(stksize,1);
if (pstk == NULL)
return(1);
#if LDATA
#if CI201A
isrss = (unsigned)((ptrtoabs(pstk) & 0xffff0L) >> 4L);
isrstk_base = (unsigned)(ptrtoabs(pstk) & 0xfL);
#else
isrss = (unsigned)(((long)(pstk) & 0xffff0L) >> 4L);
isrstk_base = (unsigned)((long)(pstk) & 0xfL);
#endif
#else
utsreg(&cs,&ss,&ds,&es); /* Return segment reg values */
isrss = ds;
isrstk_base = (unsigned)pstk;
#endif
return(0);
}